package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.entity.NursingProject;
import com.zzyl.mapper.CustomerOrdersMapper;
import com.zzyl.service.CustomerOrdersService;
import com.zzyl.vo.NursingProjectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class CustomerOrdersControllerImpl implements CustomerOrdersService {
    @Autowired
    CustomerOrdersMapper customerOrdersMapper;


    /**
     *分页查询护理项目列表
     * @param name
     * @param pageNum
     * @param pageSize
     * @param status
     * @return
     */

    @Override
    public PageResponse<NursingProjectVo> selectByPage
            (String name, Integer pageNum, Integer pageSize, Integer status) {
        PageHelper.startPage(pageNum, pageSize);
        Page<List<NursingProject>> page = customerOrdersMapper.selectByPage(name, status);
        return PageResponse.of(page, NursingProjectVo.class);
    }


    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Override
    public NursingProjectVo getById(Long id) {
       NursingProject nursingProject= customerOrdersMapper.getById(id);
       NursingProjectVo nursingProjectVo=new NursingProjectVo();
        BeanUtil.copyProperties(nursingProject,nursingProjectVo);
        return nursingProjectVo;
    }
}
